package com.ce2015.javaweb.controller;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

@RestController // 或者使用Controller
public class HelloController {

	@RequestMapping("hello")
	@ResponseBody
	public String hello(@RequestParam(defaultValue = "world") String name) {
		return "hello 11" + name + "!";
	}

	@RequestMapping("hello2")
	public ModelAndView hellojsp(@RequestParam(defaultValue = "world") String name, Model m) {
		m.addAttribute("text", "hello " + name);
		return new ModelAndView("hello");
	}
}
